#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
int main() 
{
	char ch = 0;
	int n = 0;
	FILE* pf = fopen("practice.txt", "w");
	if (pf == NULL)
	{
		perror("fopen");
		return 1;
	}
	while (scanf("%c", &ch) != EOF)
	{
		fputc(ch, pf);
	}
	fclose(pf);
	pf = NULL;
	char* arr = (char*)malloc(sizeof(char));
	if (arr == NULL)
	{
		perror("malloc");
		return 1;
	}
	char* arr2 = arr;
	pf = fopen("practice.txt", "r");
	if (pf == NULL)
	{
		perror("fopen");
		return 1;
	}
	while (*(arr+n)=fgetc(pf) != EOF)
	{
		n++;
		arr = (char*)realloc(arr, sizeof(char) * n + 2);
		if (arr == NULL)
		{
			perror("realloc");
			return 1;
		}
		arr2 = arr;
	}
	fclose(pf);
	pf = NULL;
	for (int m = 0; m <= n; m++)
	{
		printf("%c", arr2[m]);
	}
	free(arr);
	arr = NULL;
	arr2 = NULL;
	return 0;
}